#ifndef THERMAL_DATA_SAVER_HDF5_H_
#define THERMAL_DATA_SAVER_HDF5_H_

#include BS_FORCE_PLUGIN_IMPORT ()
#include "data_saver_hdf5.h"
#include BS_STOP_PLUGIN_IMPORT ()

#include "thermal_calc_model.h"

namespace blue_sky{

	template <typename strategy_t>
	struct thermal_data_saver <strategy_t>::thermal_impl : public data_saver<strategy_t>::impl
	{
		typedef data_saver<strategy_t>::impl base_t;
		typedef thermal_calc_model<strategy_t>				    thermal_calc_model_t;
		typedef smart_ptr<thermal_calc_model_t,true>		    sp_thermal_calc_model_t;
				
		thermal_impl (const std::string &name)
		: base_t(name)
		{
		}

		void
		write_calc_model_data (const sp_calc_model_t &calc_model,
			const sp_jmatrix_t &jmx,
			size_t large_time_step_num,
			size_t total_time_step_num,
			double time)
		{
			base_t::write_calc_model_data(calc_model, jmx, large_time_step_num, total_time_step_num, time);
			smart_ptr< fi_params> params = calc_model->ts_params;
			size_t save_step_data_period = params->get_int (fi_params::SAVE_STEP_DATA_PERIOD);

			sp_thermal_calc_model_t thermal_calc_model(calc_model, bs_dynamic_cast());
			hdf5_file &file = file_;

			if (large_time_step_num % save_step_data_period == 0
				|| large_time_step_num == total_time_step_num
				|| large_time_step_num == 1)
			{

				shared_vector <float> temp_data;
				write_vector ("/results/temperature", thermal_calc_model->temperature, time, temp_data);				
			}
		}
	};
}

#endif
